package com.javafactroy.kunlong.base.aspect;

import com.javafactroy.kunlong.base.annotation.CheckParams;
import com.javafactroy.kunlong.base.metadata.model.TMetadataModel;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@Aspect
public class ApiCheckParams {
    @Autowired
    TMetadataModel model;

    //@Pointcut("@annotation(com.javafactroy.kunlong.base.annotation.CheckParams)")
    @Before("@annotation(checkParams)")
    public void boBefore(JoinPoint joinPoint, CheckParams checkParams) {
        log.info("joinPoint={}", joinPoint);
        for (Object arg : joinPoint.getArgs()) {
            model.check(arg);
        }
    }


}

